home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH16 / TESTPAT.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-10-25  |  23.0 KB  |  1,257 lines

  1.         include        stdlib.a
  2.         includelib     stdlib.lib
  3.         matchfuncs
  4.  
  5. ; PATTERNS test code.
  6.  
  7. dseg        segment    para public 'data'
  8. MemAvail    dw    ?
  9.  
  10. Pat1        pattern    <MatchStr,MyStr,0,Pat1_5>
  11. MyStr        db    "Hello There",0
  12.  
  13. Pat1_5        pattern    <Spancset,Mycset,0,Pat2>
  14.  
  15. Pat2        pattern    <MatchStr,MyStr2,AltPat,Pat3>
  16. MyStr2        db    "You?",0
  17.  
  18. AltPat        pattern    <MatchStr,MyStr3,0,Pat3>
  19. MyStr3        db    "you?",0
  20.  
  21. Pat3        pattern    <EOS>
  22.  
  23.  
  24. Str2Test    db    "Hello There, how are you?"
  25. Lastbyte2tst    db    0
  26.  
  27.  
  28. ; The following pattern matches "apap" or "apapap".  I use this pattern
  29. ; to test backtracking in the matching algorithm.
  30.  
  31. APAPAP        pattern    <MatchStr,APAPstr,APAP,AP2>
  32. APAP        pattern    <MatchStr,APstr,0,AP2>
  33. AP2        pattern    <MatchStr,APstr>
  34.  
  35. APAPstr        db    "ap"
  36. APstr        db    "ap",0
  37.  
  38.  
  39. ; Some patterns to check the code in the documentation.
  40. ; HAA (has an alphabetic) checks for patterns containing at least one alphabetic
  41. ; char followed by some digits.  Alphax and Digitsx are required by the
  42. ; corresponding MatchAlpha and MatchDigits routines.
  43.  
  44. HAA        pattern    <ARB,0,0,HAA2>
  45. HAA2        pattern    <MatchAlpha,0,0,HAA3>
  46. HAA3        pattern    <MatchDigits>
  47.  
  48. Alpha1        pattern    <Anycset,alpha,0,Alpha2>
  49. Alpha2        pattern    <Spancset,alpha>
  50.  
  51. Digits1        pattern    <Anycset,digits,0,Digits2>
  52. Digits2        pattern    <Spancset,digits>
  53.  
  54.  
  55. HaaStr1        db    "ThisStringMatchesOK1234",0
  56. HaaStr2        db    "This String should match2",0
  57.  
  58.  
  59.  
  60. HAAagain    pattern    <ARB,0,0,Alpha1ormore>
  61.  
  62. Alpha1ormore    pattern    <OneOrMore,alphaset,0,Digits1ormore>
  63. AlphaSet    pattern    <Anycset,alpha>
  64.  
  65. Digits1ormore    pattern    <OneOrMore, DigitSet>
  66. DigitSet    pattern    <Anycset, digits>
  67.  
  68.  
  69. HAAadp        pattern    <arb,0,0,AlphaDigitsPat>
  70. AlphaDigitsPat    pattern    <AlphaDigits>
  71.  
  72. ParenPat    pattern    <ARB,0,0,HAAparen>
  73. HAAparen    pattern    <sl_match2,HAA2>    ;Sneaky use of match2!
  74.  
  75. ; Some patterns to check the built-in pattern matching functions:
  76.  
  77. ; Check the spancset matching function:
  78.  
  79. SCtest        pattern    <Spancset, alphanum>
  80. SCtestStr    db    "Hello there, how are you?",0
  81.  
  82. ; Check the brkcset matching fuction:
  83.  
  84. BCtest        pattern    <Brkcset, delimiters>
  85.  
  86. ; Check the MatchStr matching function:
  87.  
  88. MStest        pattern    <MatchStr, MSstr>
  89. MSstr        db    "Hello there,",0
  90.  
  91. ; Quick check of the MatchToString pattern function
  92.  
  93. MTSTest        pattern    <MatchToStr,Str2Match>
  94. Str2Match    db    "Hello there",0
  95. MainString    db    "This is a test, Hello there, how are you?",0
  96.  
  97. ; Check the MatchChar matching function:
  98.  
  99. MCtest        pattern    <MatchChar, 'H'>
  100.  
  101. ; Check the anycset matching function:
  102.  
  103. ACtest        pattern    <Anycset, alpha>
  104.  
  105. ; Check the NotAnycset matching function:
  106.  
  107. NACtest        pattern    <NotAnycset, digits>
  108. NACstr        db    "abcd, #$ 345",0
  109.  
  110. ; Check the EOS and ARB matching functions:
  111.  
  112. EOStest        pattern    <arb,0,0,EOStest2>
  113. EOStest2    pattern    <EOS>
  114.  
  115. ;Check the skip pattern matching function:
  116.  
  117. SKIPtest    pattern    <Skip, 6>
  118.  
  119. ; Check the POS pattern matching function:
  120.  
  121. POStest        pattern    <ARB,0,0,POStest2>
  122. POStest2    pattern    <POS,6>
  123.  
  124. ; Check the RPOS pattern matching function:
  125.  
  126. RPOStest    pattern    <ARB,0,0,RPOStest2>
  127. RPOStest2    pattern    <RPOS,6>
  128.  
  129. ; Check the GOTOpos pattern matching function:
  130.  
  131. GOTOposTest    pattern    <GOTOpos,6>
  132.  
  133. ; Check the RGOTOpos pattern matching function:
  134.  
  135. RGOTOposTest    pattern    <RGOTOpos, 6>
  136.  
  137. ; Check the MatchToChar pattern matching function:
  138.  
  139. Match2ChTest    pattern    <MatchToChar, ' '>
  140.  
  141.  
  142. ; Check the MatchToPat pattern matching function:
  143.  
  144. Match2PTest    pattern    <MatchToPat, Match2PTest2>
  145. Match2PTest2    pattern    <anycset, delimiters>
  146.  
  147.  
  148. ; Check the ARBNUM pattern matching function:
  149.  
  150. ArbNumTest    pattern    <MatchToStr, ArbStr, 0, ArbNumTest2>
  151. ArbNumTest2    pattern    <ArbNum,ArbNumTest3>
  152.  
  153. ArbNumTest3    pattern    <anycset, delimiters>
  154. ArbStr        db    "Hello there",0
  155.  
  156.  
  157.  
  158.  
  159. ; A character set variable for some specific tests.
  160.  
  161.         set    Mycset
  162.  
  163.  
  164. ; Bring in the standard character sets.
  165.  
  166.         include    stdsets.a
  167. dseg        ends
  168.  
  169.  
  170.  
  171. cseg        segment    para public 'code'
  172.         assume    cs:cseg, ds:dseg
  173.  
  174.  
  175.  
  176. ; Variables that wind up being used by the standard library routines.
  177. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  178. ; present if you intend to use getenv, MemInit, malloc, and free.
  179.  
  180.  
  181.         public    PSP
  182. PSP        dw    ?
  183.  
  184. cr        equ    13
  185. lf        equ    10
  186.  
  187.  
  188.  
  189.  
  190. ; MatchAlpha and MatchDigits are procedures used to test the code appearing
  191. ; in the documentation.
  192. ;
  193. ; Note that ES:DI & CX are already set up for these routines by the
  194. ; Match procedure.
  195.  
  196. MatchAlpha    proc    far        ;Must be a far proc!
  197.         push    dx
  198.         push    si        ;Preserve modified registers.
  199.         ldxi    Alpha1        ;Get pointer to "Match one or more
  200.         match2            ; alpha" pattern and match it.
  201.         pop    si
  202.         pop    dx
  203.         ret
  204. MatchAlpha    endp
  205.  
  206. MatchDigits    proc    far        ;Must be a far proc!
  207.         push    dx
  208.         push    si        ;Preserve modified registers.
  209.         ldxi    Digits1        ;Get pointer to "Match one or more
  210.         match2            ; digits" pattern and match it.
  211.         pop    si
  212.         pop    dx
  213.         ret
  214. MatchDigits    endp
  215.  
  216.  
  217.  
  218.  
  219. ; OneOrMore- Matches one or more items appearing in its MatchParm field.
  220. ;
  221. ; Assume the "MatchParm" field contains a pointer to the pattern we
  222. ; want to repeat one or more times:
  223.  
  224. OneOrMore    proc    far
  225.         push    dx
  226.         push    di
  227.  
  228.         mov    dx, ds            ;Point DX:SI at pattern.
  229.         match2                ;Make sure we get at least 1.
  230.         jnc    Fails
  231. MatchMore:      mov    di, ax            ;Move on in string.
  232.         match2
  233.         jc    MatchMore
  234.         pop    di
  235.         pop    dx
  236.         stc                ;Return success
  237.         ret
  238.  
  239. Fails:        pop    di
  240.         pop    dx
  241.         clc                ;Return failure
  242.         ret
  243. OneOrMore    endp
  244.  
  245.  
  246.  
  247. ; AlphaDigits-    Brute force way (though a little faster) to check for a
  248. ;        string which begins with one or more alpha followed by
  249. ;        one or more digits.
  250.  
  251. AlphaDigits    proc    far
  252.         push    di
  253.  
  254.         mov    al, es:[di]
  255.         and    al, 5fh            ;Convert l.c. -> U.C.
  256.         cmp    al, 'A'
  257.         jb    Failure
  258.         cmp    al, 'Z'
  259.         ja    Failure
  260. DoTheMore0:    inc    di
  261.         mov    al, es:[di]
  262.         and    al, 5fh
  263.         cmp    al, 'A'
  264.         jb    TryDigits
  265.         cmp    al, 'Z'
  266.         jbe    DoTheMore0
  267.  
  268. TryDigits:    mov    al, es:[di]
  269.         xor    al, '0'            ;See if in range '0'..'9'
  270.         cmp    al, 10
  271.         jae    Failure
  272. DoTheMore1:    inc    di
  273.         mov    al, es:[di]
  274.         xor    al, '0'
  275.         cmp    al, 10
  276.         jb    DoTheMore1
  277.         mov    ax, di            ;Return ending posn in AX.
  278.         pop    di
  279.         stc                ;Success!
  280.         ret
  281.  
  282. Failure:    mov    ax, di            ;Return failure position.
  283.         pop    di
  284.         clc                ;Return failure.
  285.         ret
  286. AlphaDigits    endp
  287.  
  288.  
  289.  
  290.  
  291.  
  292. ; PutPat-    Outputs "^" symbols at the beginning and end+1 positions
  293. ;        of a matched pattern.  ES:DI points at the pattern upon
  294. ;        entry to this routine, DS:SI points at the beginning of the
  295. ;        string.
  296.  
  297. PutPat        proc    near
  298.         push    si
  299.         push    cx
  300.         push    ax
  301.  
  302.  
  303.         mov    cx, es:[di].Pattern.StartPattern
  304.         sub    cx, si
  305.         jcxz    Nospcs
  306. PutPatLp:    mov    al, ' '
  307.         putc
  308.         loop    PutPatLp
  309. Nospcs:         mov    cx, es:[di].Pattern.EndPattern
  310.         sub    cx, es:[di].Pattern.StartPattern
  311.         jne    PutCarot
  312.         mov    al, '*'
  313.         putc
  314.         jmp    PutPatDone
  315.  
  316. PutCarot:    mov    al, '^'
  317. PutPatLp2:    putc
  318.         loop    PutPatLp2
  319.  
  320. PutPatDone:    putcr
  321.         pop    ax
  322.         pop    cx
  323.         pop    si
  324.         ret
  325. PutPat        endp
  326.  
  327.  
  328.  
  329.  
  330.  
  331. Main        proc
  332.         mov    cs:PSP, es        ;Save pgm seg prefix
  333.         mov    ax, seg dseg        ;Set up the segment registers
  334.         mov    ds, ax
  335.         mov    es, ax
  336.         mov    dx, 0            ;Allocate all available RAM.
  337.         MemInit
  338.         mov    MemAvail, cx
  339.         printf
  340.         db    "There are %x paragraphs of memory available."
  341.         db    cr,lf,lf,0
  342.         dd    MemAvail
  343.  
  344. ; Init Mycset to contain lowercase alphabetics, comma, and a space:
  345.  
  346.         lesi    Mycset
  347.         mov    al, 'a'
  348.         mov    ah, 'z'
  349.         RangeSet
  350.         AddStrl
  351.         db    " ,",0
  352.  
  353. ; Okay, see if we've got a match.  The pattern is described by the
  354. ; regular expression ["Hello There" (a-z space)* "you?"]
  355.  
  356.         printf
  357.         db    'Testing the pattern ["Hello There" (a-z space)* "you?"]'
  358.         db    cr,lf,lf
  359.         db    "String to test: %s\n",0
  360.         dd    Str2Test
  361.  
  362.         ldxi    Pat1
  363.         lesi    Str2Test
  364.         mov    cx, offset LastByte2tst
  365.         Match
  366.         jc    Matched
  367.         print
  368.         db    "Strings did not match",cr,lf,0
  369.         jmp    Test1Done
  370.  
  371. Matched:    printf
  372.         db    "The Strings did match\n"
  373.         db    "Pat1:   %2d %2d\n"
  374.         db    "Pat1_5: %2d %2d\n"
  375.         db    "Pat2:   %2d %2d\n"
  376.         db    "Alt:    %2d %2d\n"
  377.         db    "EOS:    %2d %2d\n"
  378.         db    cr,lf
  379.         db    "        %s\n"
  380.         db    0
  381.         dd    Pat1.StartPattern, Pat1.EndPattern
  382.         dd    Pat1_5.StartPattern, Pat1_5.EndPattern
  383.         dd    Pat2.StartPattern, Pat2.EndPattern
  384.         dd    AltPat.StartPattern, AltPat.EndPattern
  385.         dd    Pat3.StartPattern, Pat3.EndPattern
  386.         dd    Str2Test
  387.  
  388.         lea    si, Str2Test
  389.         print
  390.         db    "Pat1:   ",0
  391.         lesi    Pat1
  392.         call    PutPat
  393.  
  394.         print
  395.         db    "Pat1_5: ",0
  396.         lesi    Pat1_5
  397.         call    PutPat
  398.  
  399.         print
  400.         db    "Pat2:   ",0
  401.         lesi    Pat2
  402.         call    PutPat
  403.  
  404.         print
  405.         db    "Alt:    ",0
  406.         lesi    AltPat
  407.         call    PutPat
  408.  
  409.         print
  410.         db    "EOS:   ",0
  411.         lesi    Pat3
  412.         call    PutPat
  413.  
  414.  
  415. Test1Done:
  416.  
  417.         printf
  418.         db    cr,lf,lf
  419.         db    'Testing the pattern ["APAP" | "AP"] "AP"',cr,lf
  420.         db    "String to test: %s\n\n",0
  421.         dd    APAPstr
  422.  
  423.         lesi    APAPstr
  424.         ldxi    APAPAP
  425.         mov    cx, 0
  426.         match
  427.         jc    MatchedAP
  428.         print
  429.         db    "Error: should have matched 'apap'",cr,lf,0
  430.         jmp    Test2Done
  431.  
  432. MatchedAP:    printf
  433.         db    "Properly matched 'apap'",cr,lf
  434.         db    "APAPAP: %3d %3d",cr,lf
  435.         db    "APAP:   %3d %3d",cr,lf
  436.         db    "AP2:    %3d %3d",cr,lf
  437.         db    cr,lf
  438.         db    "        %s",cr,lf
  439.         db    0
  440.         dd    APAPAP.startpattern, APAPAP.endpattern
  441.         dd    APAP.startpattern, APAP.endpattern
  442.         dd    AP2.startpattern, AP2.endpattern
  443.         dd      APAPStr
  444.  
  445.         lea    si, APAPStr
  446.         print
  447.         db    "APAPAP: ",0
  448.         lesi    APAPAP
  449.         call    PutPat
  450.         print
  451.         db    "APAP:   ",0
  452.         lesi    APAP
  453.         call    PutPat
  454.         print
  455.         db    "AP2:    ",0
  456.         lesi    AP2
  457.         call    PutPat
  458.  
  459. Test2Done:
  460.  
  461. ; Now let's run some tests to verify the code in the documentation:
  462.  
  463.         print
  464.         db    cr,lf,lf
  465.         db    "Testing the pattern 'ARB [a-zA-Z]+ [0-9]+'"
  466.         db    cr,lf,lf,0
  467.         ldxi    HAA
  468.         lesi    HaaStr1
  469.         xor    cx, cx
  470.         match
  471.         jnc    HAADidntWork1
  472.         print
  473.         db    "HAA properly matched HaaStr1",cr,lf
  474.         db    "Starting address:  ",0
  475.         lea    ax, HaaStr1
  476.         putw
  477.         printf
  478.         db    cr,lf
  479.         db    "ARB component:     %4x %4x\n"
  480.         db    "Alpha component:   %4x %4x\n"
  481.         db    "Numeric component: %4x %4x\n\n"
  482.         db    "      %s\n",0
  483.         dd    Haa.StartPattern,  Haa.EndPattern
  484.         dd    Haa2.StartPattern, Haa2.EndPattern
  485.         dd    Haa3.StartPattern, Haa3.EndPattern
  486.         dd    HaaStr1
  487.  
  488.  
  489.         lea    si, HaaStr1
  490.         print
  491.         db    "HAA:  ",0
  492.         lesi    HAA
  493.         call    PutPat
  494.  
  495.         print
  496.         db    "HAA2: ",0
  497.         lesi    HAA2
  498.         call    PutPat
  499.  
  500.         print
  501.         db    "HAA3: ",0
  502.         lesi    HAA3
  503.         call    PutPat
  504.         jmp    Test3Done
  505.  
  506. HAADidntWork1:    print
  507.         db    "HAA failed to match HaaStr1",cr,lf,0
  508.  
  509. Test3Done:
  510.  
  511.         print
  512.         db    cr,lf,lf
  513.         db    "Testing the pattern 'ARB [a-zA-Z]+ [0-9]+'"
  514.         db    cr,lf,lf,0
  515.         ldxi    HAA
  516.         lesi    HaaStr2
  517.         xor    cx, cx
  518.         match
  519.         jnc    HAADidntWork2
  520.         print
  521.         db    "HAA properly matched HaaStr2",cr,lf
  522.         db    "Starting address:  ",0
  523.         lea    ax, HaaStr2
  524.         putw
  525.         printf
  526.         db    cr,lf
  527.         db    "ARB component:     %4x %4x\n"
  528.         db    "Alpha component:   %4x %4x\n"
  529.         db    "Numeric component: %4x %4x\n\n"
  530.         db    "      %s\n",0
  531.         dd    Haa.StartPattern,  Haa.EndPattern
  532.         dd    Haa2.StartPattern, Haa2.EndPattern
  533.         dd    Haa3.StartPattern, Haa3.EndPattern
  534.         dd    HaaStr2
  535.  
  536.  
  537.         lea    si, HaaStr2
  538.         print
  539.         db    "HAA:  ",0
  540.         lesi    HAA
  541.         call    PutPat
  542.  
  543.         print
  544.         db    "HAA2: ",0
  545.         lesi    HAA2
  546.         call    PutPat
  547.  
  548.         print
  549.         db    "HAA3: ",0
  550.         lesi    HAA3
  551.         call    PutPat
  552.         jmp    Test4Done
  553.  
  554. HAADidntWork2:    print
  555.         db    "HAA failed to match HaaStr2",cr,lf,0
  556.  
  557. Test4Done:
  558.  
  559.         print
  560.         db    cr,lf,lf
  561.         db    "Testing the pattern 'ARB [a-zA-Z]+ [0-9]+' "
  562.         db    "using OneOrMore pattern"
  563.         db    cr,lf,lf,0
  564.  
  565.         ldxi    HAAagain
  566.         lesi    HaaStr1
  567.         xor    cx, cx
  568.         match
  569.         jnc    HAADidntWork3
  570.         print
  571.         db    "HAAagain properly matched HaaStr1",cr,lf
  572.         db    "Starting address:  ",0
  573.         lea    ax, HaaStr1
  574.         putw
  575.         printf
  576.         db    cr,lf
  577.         db    "ARB component:     %4x %4x\n"
  578.         db    "Alpha1 component:  %4x %4x\n"
  579.         db    "Alpha2 component:  %4x %4x\n"
  580.         db    "Digits1 component: %4x %4x\n"
  581.         db    "Digits2 component: %4x %4x\n\n"
  582.         db    "         %s\n",0
  583.         dd    HAAagain.StartPattern,  HAAagain.EndPattern
  584.         dd    Alpha1ormore.StartPattern, Alpha1ormore.EndPattern
  585.         dd    Alphaset.StartPattern, Alphaset.EndPattern
  586.         dd    Digits1ormore.StartPattern, Digits1ormore.EndPattern
  587.         dd    DigitSet.StartPattern, DigitSet.EndPattern
  588.         dd    HaaStr1
  589.  
  590.  
  591.         lea    si, HaaStr1
  592.         print
  593.         db    "ARB:     ",0
  594.         lesi    HAAagain
  595.         call    PutPat
  596.  
  597.         print
  598.         db    "Alpha1:  ",0
  599.         lesi    Alpha1ormore
  600.         call    PutPat
  601.  
  602.         print
  603.         db    "Alpha2:  ",0
  604.         lesi    AlphaSet
  605.         call    PutPat
  606.  
  607.         print
  608.         db    "Digits1: ",0
  609.         lesi    Digits1ormore
  610.         call    PutPat
  611.  
  612.         print
  613.         db    "Digits2: ",0
  614.         lesi    DigitSet
  615.         call    PutPat
  616.  
  617.         jmp    Test5Done
  618.  
  619. HAADidntWork3:    print
  620.         db    "HAAagain failed to match HaaStr1",cr,lf,0
  621.  
  622. Test5Done:
  623.  
  624.  
  625.         print
  626.         db    cr,lf,lf
  627.         db    "Testing the pattern 'ARB [a-zA-Z]+ [0-9]+' "
  628.         db    "using AlphaDigits pattern"
  629.         db    cr,lf,lf,0
  630.  
  631.         ldxi    HAAadp
  632.         lesi    HaaStr1
  633.         xor    cx, cx
  634.         match
  635.         jnc    HAADidntWork4
  636.         print
  637.         db    "AlphaDigitsPat properly matched HaaStr1",cr,lf
  638.         db    "Starting address:  ",0
  639.         lea    ax, HaaStr1
  640.         putw
  641.         printf
  642.         db    cr,lf
  643.         db    "ARB component:          %4x %4x\n"
  644.         db    "AlphaDigits component:  %4x %4x\n"
  645.         db    "                 %s\n",0
  646.         dd    HAAadp.StartPattern,  HAAadp.EndPattern
  647.         dd    AlphaDigitsPat.StartPattern
  648.         dd    AlphaDigitsPat.EndPattern
  649.         dd    HaaStr1
  650.  
  651.  
  652.         lea    si, HaaStr1
  653.         print
  654.         db    "ARB:             ",0
  655.         lesi    HAAadp
  656.         call    PutPat
  657.  
  658.         print
  659.         db    "AlphaDigitsPat:  ",0
  660.         lesi    AlphaDigitsPat
  661.         call    PutPat
  662.  
  663.         jmp    Test6Done
  664.  
  665. HAADidntWork4:    print
  666.         db    "HAAagain failed to match HaaStr1",cr,lf,0
  667.  
  668. Test6Done:
  669.  
  670.  
  671.         print
  672.         db    cr,lf,lf
  673.         db    "Testing the pattern 'ARB [a-zA-Z]+ [0-9]+' "
  674.         db    "using ParenPat pattern"
  675.         db    cr,lf,lf,0
  676.  
  677.  
  678.         ldxi    ParenPat
  679.         lesi    HaaStr1
  680.         xor    cx, cx
  681.         match
  682.         jnc    HAADidntWork5
  683.         print
  684.         db    "ParenPat properly matched HaaStr1",cr,lf
  685.         db    "Starting address:  ",0
  686.         lea    ax, HaaStr1
  687.         putw
  688.         printf
  689.         db    cr,lf
  690.         db    "ARB component:       %4x %4x\n"
  691.         db    "ParenPat component:  %4x %4x\n"
  692.         db    "HAA2 component:      %4x %4x\n"
  693.         db    "HAA3 component:      %4x %4x\n"
  694.         db    "           %s\n",0
  695.         dd    ParenPat.StartPattern,  ParenPat.EndPattern
  696.         dd    HAAparen.StartPattern,  HAAparen.EndPattern
  697.         dd    HAA2.StartPattern, HAA2.EndPattern
  698.         dd    HAA3.StartPattern, HAA3.EndPattern
  699.         dd    HaaStr1
  700.  
  701.  
  702.         lea    si, HaaStr1
  703.         print
  704.         db    "ARB:       ",0
  705.         lesi    ParenPat
  706.         call    PutPat
  707.  
  708.         print
  709.         db    "ParenPat:  ",0
  710.         lesi    HAAParen
  711.         call    PutPat
  712.  
  713.         print
  714.         db    "HAA2:      ",0
  715.         lesi    HAA2
  716.         call    PutPat
  717.  
  718.         print
  719.         db    "HAA3:      ",0
  720.         lesi    HAA3
  721.         call    PutPat
  722.         jmp    Test7Done
  723.  
  724. HAADidntWork5:    print
  725.         db    "HAAagain failed to match HaaStr1",cr,lf,0
  726.  
  727. Test7Done:
  728.  
  729.         print
  730.         db    cr,lf
  731.         db    "Testing MatchToString:",cr,lf,lf,0
  732.  
  733.         ldxi    MTStest
  734.         lesi    MainString
  735.         xor    cx, cx
  736.         Match
  737.         jnc    MTSFailed
  738.         printf
  739.         db    "MatchToString worked",cr,lf
  740.         db    "Character range: %4x %4x",cr,lf,lf
  741.         db    "               %s",cr,lf,0
  742.         dd    MTStest.StartPattern, MTStest.EndPattern
  743.         dd    MainString
  744.  
  745.         lea    si, MainString
  746.         print
  747.         db    "MatchToString: ",0
  748.         lesi    MTStest
  749.         call    PutPat
  750.         jmp    Test8Done
  751.  
  752. MTSFailed:    print
  753.         db    "MatchToString did not work",cr,lf,0
  754.  
  755. Test8Done:
  756.  
  757.         print
  758.         db    cr,lf
  759.         db    "Testing Spancset:",cr,lf,lf,0
  760.  
  761.         ldxi    SCtest
  762.         lesi    SCtestStr
  763.         xor    cx, cx
  764.         Match
  765.         jnc    SCFailed
  766.         printf
  767.         db    "Spancset worked",cr,lf
  768.         db    "Character range: %4x %4x",cr,lf,lf
  769.         db    "          %s",cr,lf,0
  770.         dd    SCtest.StartPattern, SCtest.EndPattern
  771.         dd      SCtestStr
  772.  
  773.         lea    si,  SCTestStr
  774.         print
  775.         db    "Spancset: ",0
  776.         lesi    SCtest
  777.         call    PutPat
  778.         jmp    Test9Done
  779.  
  780. SCFailed:    print
  781.         db    "Spancset did not work",cr,lf,0
  782.  
  783. Test9Done:
  784.  
  785.         print
  786.         db    cr,lf
  787.         db    "Testing Brkcset:",cr,lf,lf,0
  788.  
  789.         ldxi    BCtest
  790.         lesi    SCtestStr
  791.         xor    cx, cx
  792.         Match
  793.         jnc    BCFailed
  794.         printf
  795.         db    "Brkcset worked",cr,lf
  796.         db    "Character range: %4x %4x",cr,lf,lf
  797.         db    "         %s",cr,lf,0
  798.         dd    BCtest.StartPattern, BCtest.EndPattern
  799.         dd      SCtestStr
  800.  
  801.         lea    si,  SCTestStr
  802.         print
  803.         db    "Brkcset: ",0
  804.         lesi    BCtest
  805.         call    PutPat
  806.         jmp    Test10Done
  807.  
  808. BCFailed:    print
  809.         db    "Brkcset did not work",cr,lf,0
  810.  
  811. Test10Done:
  812.  
  813.         print
  814.         db    cr,lf
  815.         db    "Testing MatchStr:",cr,lf,lf,0
  816.  
  817.         ldxi    MStest
  818.         lesi    SCtestStr
  819.         xor    cx, cx
  820.         Match
  821.         jnc    MSFailed
  822.         printf
  823.         db    "MatchString worked",cr,lf
  824.         db    "Character range: %4x %4x",cr,lf,lf
  825.         db    "          %s",cr,lf,0
  826.         dd    MStest.StartPattern, MStest.EndPattern
  827.         dd      SCtestStr
  828.  
  829.         lea    si,  SCTestStr
  830.         print
  831.         db    "MatchStr: ",0
  832.         lesi    MStest
  833.         call    PutPat
  834.         jmp    Test11Done
  835.  
  836. MSFailed:    print
  837.         db    "MatchStr did not work",cr,lf,0
  838.  
  839. Test11Done:
  840.  
  841.  
  842.         print
  843.         db    cr,lf
  844.         db    "Testing MatchChar:",cr,lf,lf,0
  845.  
  846.         ldxi    MCtest
  847.         lesi    SCtestStr
  848.         xor    cx, cx
  849.         Match
  850.         jnc    MCFailed
  851.         printf
  852.         db    "MatchChar worked",cr,lf
  853.         db    "Character range: %4x %4x",cr,lf,lf
  854.         db    "           %s",cr,lf,0
  855.         dd    MCtest.StartPattern, MCtest.EndPattern
  856.         dd      SCtestStr
  857.  
  858.         lea    si,  SCTestStr
  859.         print
  860.         db    "MatchChar: ",0
  861.         lesi    MCtest
  862.         call    PutPat
  863.         jmp    Test12Done
  864.  
  865. MCFailed:    print
  866.         db    "MatchChar did not work",cr,lf,0
  867.  
  868. Test12Done:
  869.  
  870.  
  871.         print
  872.         db    cr,lf
  873.         db    "Testing Anycset:",cr,lf,lf,0
  874.  
  875.         ldxi    ACtest
  876.         lesi    SCtestStr
  877.         xor    cx, cx
  878.         Match
  879.         jnc    ACFailed
  880.         printf
  881.         db    "Anycset worked",cr,lf
  882.         db    "Character range: %4x %4x",cr,lf,lf
  883.         db    "         %s",cr,lf,0
  884.         dd    ACtest.StartPattern, ACtest.EndPattern
  885.         dd      SCtestStr
  886.  
  887.         lea    si,  SCTestStr
  888.         print
  889.         db    "Anycset: ",0
  890.         lesi    ACtest
  891.         call    PutPat
  892.         jmp    Test13Done
  893.  
  894. ACFailed:    print
  895.         db    "Anycset did not work",cr,lf,0
  896.  
  897. Test13Done:
  898.  
  899.         print
  900.         db    cr,lf
  901.         db    "Testing NotAnycset:",cr,lf,lf,0
  902.  
  903.         ldxi    NACtest
  904.         lesi    NACStr
  905.         xor    cx, cx
  906.         Match
  907.         jnc    NACFailed
  908.         printf
  909.         db    "NotAnycset worked",cr,lf
  910.         db    "Character range: %4x %4x",cr,lf,lf
  911.         db    "               %s",cr,lf,0
  912.         dd    NACtest.StartPattern, NACtest.EndPattern
  913.         dd      NACStr
  914.  
  915.         lea    si,  NACStr
  916.         print
  917.         db    "NotAnycset:    ",0
  918.         lesi    NACtest
  919.         call    PutPat
  920.         jmp    Test14Done
  921.  
  922. NACFailed:    print
  923.         db    "NotAnycset did not work",cr,lf,0
  924.  
  925. Test14Done:
  926.  
  927.  
  928.  
  929.         print
  930.         db    cr,lf
  931.         db    "Testing ARB/EOS:",cr,lf,lf,0
  932.  
  933.         ldxi    EOStest
  934.         lesi    SCtestStr
  935.         xor    cx, cx
  936.         Match
  937.         jnc    EOSFailed
  938.         printf
  939.         db    "EOS/ARB worked",cr,lf
  940.         db    "ARB range:    %4x %4x",cr,lf
  941.         db    "EOS position: %4x %4x",cr,lf,lf
  942.         db    "       %s",cr,lf,0
  943.         dd    EOStest.StartPattern, EOStest.EndPattern
  944.         dd    EOStest2.StartPattern, EOStest2.EndPattern
  945.         dd      SCtestStr
  946.  
  947.         lea    si,  SCtestStr
  948.         print
  949.         db    "ARB:   ",0
  950.         lesi    EOStest
  951.         call    PutPat
  952.  
  953.         print
  954.         db    "EOS:   ",0
  955.         lesi    EOStest2
  956.         call    PutPat
  957.         jmp    Test15Done
  958.  
  959. EOSFailed:    print
  960.         db    "EOS/ARB did not work",cr,lf,0
  961.  
  962. Test15Done:
  963.  
  964.  
  965.  
  966.         print
  967.         db    cr,lf
  968.         db    "Testing Skip:",cr,lf,lf,0
  969.  
  970.         ldxi    SKIPtest
  971.         lesi    SCtestStr
  972.         xor    cx, cx
  973.         Match
  974.         jnc    SkipFailed
  975.         printf
  976.         db    "Skip worked",cr,lf
  977.         db    "Character range: %4x %4x",cr,lf,lf
  978.         db    "       %s",cr,lf,0
  979.         dd    Skiptest.StartPattern, Skiptest.EndPattern
  980.         dd      SCtestStr
  981.  
  982.         lea    si,  SCtestStr
  983.         print
  984.         db    "Skip:  ",0
  985.         lesi    SkipTest
  986.         call    PutPat
  987.         jmp    Test16Done
  988.  
  989. SkipFailed:    print
  990.         db    "Skip did not work",cr,lf,0
  991.  
  992. Test16Done:
  993.  
  994.  
  995.  
  996.         print
  997.         db    cr,lf
  998.         db    "Testing ARB/POS:",cr,lf,lf,0
  999.  
  1000.         ldxi    POStest
  1001.         lesi    SCtestStr
  1002.         xor    cx, cx
  1003.         Match
  1004.         jnc    POSFailed
  1005.         printf
  1006.         db    "POS/ARB worked",cr,lf
  1007.         db    "ARB range:    %4x %4x",cr,lf
  1008.         db    "POS position: %4x %4x",cr,lf,lf
  1009.         db    "       %s",cr,lf,0
  1010.         dd    POStest.StartPattern, POStest.EndPattern
  1011.         dd    POStest2.StartPattern, POStest2.EndPattern
  1012.         dd      SCtestStr
  1013.  
  1014.         lea    si,  SCtestStr
  1015.         print
  1016.         db    "ARB:   ",0
  1017.         lesi    POStest
  1018.         call    PutPat
  1019.  
  1020.         print
  1021.         db    "POS:   ",0
  1022.         lesi    POStest2
  1023.         call    PutPat
  1024.         jmp    Test17Done
  1025.  
  1026. POSFailed:    print
  1027.         db    "POS/ARB did not work",cr,lf,0
  1028.  
  1029. Test17Done:
  1030.  
  1031.  
  1032.  
  1033.         print
  1034.         db    cr,lf
  1035.         db    "Testing ARB/RPOS:",cr,lf,lf,0
  1036.  
  1037.         ldxi    RPOStest
  1038.         lesi    SCtestStr
  1039.         xor    cx, cx
  1040.         Match
  1041.         jnc    RPOSFailed
  1042.         printf
  1043.         db    "RPOS/ARB worked",cr,lf
  1044.         db    "ARB range:    %4x %4x",cr,lf
  1045.         db    "RPOS position: %4x %4x",cr,lf,lf
  1046.         db    "       %s",cr,lf,0
  1047.         dd    RPOStest.StartPattern, RPOStest.EndPattern
  1048.         dd    RPOStest2.StartPattern, RPOStest2.EndPattern
  1049.         dd      SCtestStr
  1050.  
  1051.         lea    si,  SCtestStr
  1052.         print
  1053.         db    "ARB:   ",0
  1054.         lesi    RPOStest
  1055.         call    PutPat
  1056.  
  1057.         print
  1058.         db    "RPOS:  ",0
  1059.         lesi    RPOStest2
  1060.         call    PutPat
  1061.         jmp    Test18Done
  1062.  
  1063. RPOSFailed:    print
  1064.         db    "RPOS/ARB did not work",cr,lf,0
  1065.  
  1066. Test18Done:
  1067.  
  1068.  
  1069.  
  1070.         print
  1071.         db    cr,lf
  1072.         db    "Testing GOTOpos:",cr,lf,lf,0
  1073.  
  1074.         ldxi    GOTOposTest
  1075.         lesi    SCtestStr
  1076.         xor    cx, cx
  1077.         Match
  1078.         jnc    GOTOFailed
  1079.         printf
  1080.         db    "GOTOpos worked",cr,lf
  1081.         db    "Character range: %4x %4x",cr,lf,lf
  1082.         db    "          %s",cr,lf,0
  1083.         dd    GOTOposTest.StartPattern, GOTOposTest.EndPattern
  1084.         dd      SCtestStr
  1085.  
  1086.         lea    si,  SCtestStr
  1087.         print
  1088.         db    "GOTOpos:  ",0
  1089.         lesi    SkipTest
  1090.         call    PutPat
  1091.         jmp    Test19Done
  1092.  
  1093. GOTOFailed:    print
  1094.         db    "GOTOpos did not work",cr,lf,0
  1095.  
  1096. Test19Done:
  1097.  
  1098.  
  1099.  
  1100.         print
  1101.         db    cr,lf
  1102.         db    "Testing RGOTOpos:",cr,lf,lf,0
  1103.  
  1104.         ldxi    RGOTOposTest
  1105.         lesi    SCtestStr
  1106.         xor    cx, cx
  1107.         Match
  1108.         jnc    RGOTOFailed
  1109.         printf
  1110.         db    "RGOTOpos worked",cr,lf
  1111.         db    "Character range: %4x %4x",cr,lf,lf
  1112.         db    "           %s",cr,lf,0
  1113.         dd    RGOTOposTest.StartPattern, RGOTOposTest.EndPattern
  1114.         dd      SCtestStr
  1115.  
  1116.         lea    si,  SCtestStr
  1117.         print
  1118.         db    "RGOTOpos:  ",0
  1119.         lesi    RGOTOposTest
  1120.         call    PutPat
  1121.         jmp    Test20Done
  1122.  
  1123. RGOTOFailed:    print
  1124.         db    "RGOTOpos did not work",cr,lf,0
  1125.  
  1126. Test20Done:
  1127.  
  1128.  
  1129.  
  1130.         print
  1131.         db    cr,lf
  1132.         db    "Testing MatchToChar:",cr,lf,lf,0
  1133.  
  1134.         ldxi    Match2Chtest
  1135.         lesi    SCtestStr
  1136.         xor    cx, cx
  1137.         Match
  1138.         jnc    MTCFailed
  1139.         printf
  1140.         db    "MatchToChar worked",cr,lf
  1141.         db    "Character range: %4x %4x",cr,lf,lf
  1142.         db    "             %s",cr,lf,0
  1143.         dd    Match2ChTest.StartPattern, Match2ChTest.EndPattern
  1144.         dd      SCtestStr
  1145.  
  1146.         lea    si,  SCtestStr
  1147.         print
  1148.         db    "MatchToChar: ",0
  1149.         lesi    Match2ChTest
  1150.         call    PutPat
  1151.         jmp    Test21Done
  1152.  
  1153. MTCFailed:    print
  1154.         db    "MatchToChar did not work",cr,lf,0
  1155.  
  1156. Test21Done:
  1157.  
  1158.  
  1159.  
  1160.         print
  1161.         db    cr,lf
  1162.         db    "Testing MatchToPat:",cr,lf,lf,0
  1163.  
  1164.         ldxi    Match2Ptest
  1165.         lesi    SCtestStr
  1166.         xor    cx, cx
  1167.         Match
  1168.         jnc    MTPFailed
  1169.         printf
  1170.         db    "MatchToPat worked",cr,lf
  1171.         db    "Character range: %4x %4x",cr,lf
  1172.         db    "Pattern range: %4x %4x",cr,lf,lf
  1173.         db    "             %s",cr,lf,0
  1174.         dd    Match2PTest.StartPattern, Match2PTest.EndPattern
  1175.         dd    Match2PTest2.StartPattern, Match2PTest2.EndPattern
  1176.         dd      SCtestStr
  1177.  
  1178.         lea    si,  SCtestStr
  1179.         print
  1180.         db    "MatchToPat:  ",0
  1181.         lesi    Match2PTest
  1182.         call    PutPat
  1183.  
  1184.         print
  1185.         db    "MatchToPat2: ",0
  1186.         lesi    Match2PTest2
  1187.         call    PutPat
  1188.         jmp    Test22Done
  1189.  
  1190. MTPFailed:    print
  1191.         db    "MatchToPat did not work",cr,lf,0
  1192.  
  1193. Test22Done:
  1194.  
  1195.  
  1196.  
  1197.         print
  1198.         db    cr,lf
  1199.         db    "Testing ARBNUM:",cr,lf,lf,0
  1200.  
  1201.         ldxi    ArbNumtest
  1202.         lesi    SCtestStr
  1203.         xor    cx, cx
  1204.         Match
  1205.         jnc    ARBNumFailed
  1206.         printf
  1207.         db    "ARBNUM worked",cr,lf
  1208.         db    "Character range: %4x %4x",cr,lf
  1209.         db    "Pattern range: %4x %4x",cr,lf,lf
  1210.         db    "           %s",cr,lf,0
  1211.         dd    ArbNumTest.StartPattern, ArbNumTest.EndPattern
  1212.         dd    ArbNumTest2.StartPattern, ArbNumTest2.EndPattern
  1213.         dd      SCtestStr
  1214.  
  1215.         lea    si,  SCtestStr
  1216.         print
  1217.         db    "MatchStr:  ",0
  1218.         lesi    ArbNumTest
  1219.         call    PutPat
  1220.  
  1221.         print
  1222.         db    "ARBNUM:    ",0
  1223.         lesi    ArbNumTest2
  1224.         call    PutPat
  1225.         jmp    Test23Done
  1226.  
  1227. ArbNumFailed:    print
  1228.         db    "ARBNUM did not work",cr,lf,0
  1229.  
  1230. Test23Done:
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236. Quit:        mov     ah, 4ch
  1237.         int     21h
  1238. Main        endp
  1239.  
  1240. cseg            ends
  1241.  
  1242. ; Allocate a reasonable amount of space for the stack (2k).
  1243.  
  1244. sseg        segment    para stack 'stack'
  1245. stk        db    256 dup ("stack   ")
  1246. sseg        ends
  1247.  
  1248.  
  1249.  
  1250. ; zzzzzzseg must be the last segment that gets loaded into memory!
  1251.  
  1252. zzzzzzseg    segment    para public 'zzzzzz'
  1253. LastBytes    db    16 dup (?)
  1254. heap        db    1024 dup (?)
  1255. zzzzzzseg    ends
  1256.         end    Main
  1257.